
package suncertify.middle;

//~--- JDK imports ------------------------------------------------------------

import java.util.ArrayList;

/**
 *
 * @author jshah
 * interface which defines messages/queries client sends to server/DBAccess class
 *
 */
public interface ClientBroker {

    /**
     * Set the dbpath to locate the database file to be used by the DBAccess file
     * @param path the absolute path of the db file
     * @return returns true if file was located and DBAccess was instantiated using this file
     */
    public boolean setDbPath(String path);

    /**
     * overloaded version of <code>seDbPath</code> in cases where client is in RMI mode as the Database file is selected
     * by the server administrator in such cases, client just has to know which server it wants to connect and call this method,
     * Server will pick up the database file from its properties file
     * @return returns true if a valid db file is found and <code>DBAccess</code> instance is successfully instantiated
     */
    public boolean setDbPath();
    
    /**
     *
     * @param name      Name of the contractor to search
     * @param Location  Location of the contractor to search
     * @return <code>ArrayList<String[]></code> Returns a collection of <String[]> which contains the data of that record 
     */
    public ArrayList<String[]> searchRecords(String name, String Location);

    /**
     * calls the book method on the server side, which updates the "bookedby" field of the record
     * @param recNo       Record# to locate the Record in DB
     * @param customerID  4digit customer id to identify the customer which has hired that contractor
     * @return            Returns a byte representing success or error booking
     */
    public String book(int recNo, String customerID);

    /**
     * calls the unbook method on the server side, which updates the "bookedby" field of record and writes all spaces
     * in the field Record# to locate the Record in DB
     * @param recNo      4digit customer id to identify the customer which has hired that contractor
     * @return           Returns a byte representing success or error booking
     */
    public String unbook(int recNo);

    /**
     * get the current record data by locating the recNo in the database file
     * @param recNo     the recordNo of the desired record
     * @return         <code>String[]</code> representing the data of the current record
     */
    public String[] read(int recNo);
}


